package com.agricultural.environment;

import java.util.Random;

public class SoilPHSensor implements Sensor {
    private Random random = new Random();
    private double offset = 0;

    @Override
    public double readValue() {
        // 模拟土壤pH值读数 (5-8)
        return 5 + random.nextDouble() * 3 + offset;
    }

    @Override
    public void calibrate() {
        // 模拟校准过程
        offset = (random.nextDouble() - 0.5) * 0.5; // 随机偏移 (-0.25 到 0.25)
        System.out.println("土壤pH值传感器校准完成，偏移量: " + offset);
    }
}    